import json
import requests

headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
}


# 历史温度
def historicalTmp(city, code, year, month):
    weather_url = f'https://www.qweather.com/v2/historical/cid/{city}-{str(code)}/year/{str(year)}/month/{str(month)}.json'
    response = requests.get(url=weather_url, headers=headers)
    json_data = json.loads(response.text)
    # print(json_data['data'])
    data = json_data['data']
    return data


historicalTmp('guangzhou', 101280101, 2022, 11)